﻿/*
 * 由SharpDevelop创建。
 * 用户： Administrator
 * 日期: 2024/12/20
 * 时间: 11:05
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using com.nlf.calendar;

namespace rili
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		[DllImport("user32.dll")]
		public static extern bool ReleaseCapture();
		[DllImport("user32.dll")]
		public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
		public const int WM_SYSCOMMAND = 0x0112;
		public const int SC_MOVE = 0xF010;
		public const int HTCAPTION = 0x0002;
		
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			 
			Solar solar = new Solar(DateTime.Today.Year,DateTime.Today.Month,DateTime.Today.Day);
             
			label1.Text=DateTime.Today.Year.ToString()+"年"+DateTime.Today.Month.ToString()+"月";
			label2.Text=DateTime.Today.Day.ToString();
			label3.Text="星期"+solar.getWeekInChinese()+" "+solar.getXingZuo()+"座";
			Lunar lunar = solar.getLunar();
			label4.Text=lunar.toString();
			if (solar.getFestivals().Count>0 && lunar.getJieQi()!="") {
				label5.Text=solar.getFestivals()[0]+" "+lunar.getJieQi();
			}
			else if (solar.getFestivals().Count==0 && lunar.getJieQi()!="") {
				label5.Text=lunar.getJieQi();
			}
			else if (solar.getFestivals().Count==0 && lunar.getJieQi()=="") {
				label5.Text="今天不过节";
			}
           // 宜
			List<string> l = lunar.getDayYi();
			foreach(string s in l)
			{
				label8.Text+=s+"\n";
			}
			// 忌
			l = lunar.getDayJi();
			foreach(string s in l)
			{
			  label9.Text+=s+"\n";
			}
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		void Label1MouseDown(object sender, MouseEventArgs e)
		{
			ReleaseCapture();
			SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
		}
		void ExitToolStripMenuItemClick(object sender, EventArgs e)
		{
			this.Close();
		}
		int n=0;
		void ColorToolStripMenuItemClick(object sender, EventArgs e)
		{
			n++;
			if (n%2!=0) {
				label1.BackColor=Color.DodgerBlue;
				colorToolStripMenuItem.Text="红色";
			}else{
				label1.BackColor=Color.Tomato;
				colorToolStripMenuItem.Text="蓝色";
			}
		}
		int t=0;
		void TopToolStripMenuItemClick(object sender, EventArgs e)
		{
			t++;
			if (t%2!=0) {
				this.TopMost = true;
				topToolStripMenuItem.Text="不置顶";
			}else{
				this.TopMost = false;
				topToolStripMenuItem.Text="置顶";
			}
		}
	}
}
